<?php
/*$gen=2;
$matkul=10;
$jadwal=20;
//include query3.php;
for ($a=1;$a<=$matkul;$a++){
echo $htggg2[$a]=mt_rand(10, 130);
}
echo "<br/>";


for ($a=1;$a<$gen;$a++){
	for ($b=1;$b<$matkul;$b++){
	$krom[$a][$b]=mt_rand(1,$jadwal);
	echo $krom[$a][$b].":";
	}
echo "<br />";
}
echo "<br/>";
for ($a=1;$a<$gen;$a++){

	for ($b=1;$b<$matkul;$b++){
	$gg[$b]=$krom[$a][$b];
	}
	$yuk2=dicek($gg, $jadwal, $matkul, $htggg2);
}


	for ($b=1;$b<$matkul;$b++){
	echo $yuk2[$b].":";
}
*/






function dicek ($yuk, $jadwal, $matkul, $htggg2){
$yuk2=$yuk;
for($urut_f=1;$urut_f<=$jadwal;$urut_f++){
$urutp=1;
$urutpp=0;
	for($urut_ff=1;$urut_ff<=$matkul;$urut_ff++){
		if($yuk[$urut_ff]==$urut_f){
		$urutpp++;
		//echo $urutp;
		$uruttt[$urut_f][$urutpp]=$urutp;
		echo $urut_f."-".$urutpp.": ".$urutp."<br/>";
		}
	$urutp++;
	}
$j_urut[$urut_f]=$urutpp;
//echo $j_urut[$urut_f]."<br/>";

$htgggg3=0;
	if ($j_urut[$urut_f]>0){
		for($b=1;$b<=$j_urut[$urut_f];$b++){
		$lalala=$uruttt[$urut_f][$b];
		echo $htggg2[$lalala]."-";
		$htgggg3=$htgggg3+$htggg2[$lalala];
		}
	echo $htgggg3;
	if ($htgggg3>136)
		{
		unset($yuk[$urutp]);
		echo "*".$yuk[$lalala]= $urut_f+1;
		}
	echo "<br/>\n";
	}
	
}

echo "<br/>\n";
return $yuk;
}


?>
